﻿<%@ Page Title="" Language="C#" MasterPageFile="~/admin/admin.Master" AutoEventWireup="true" CodeBehind="ManageCategory.aspx.cs" Inherits="spk_eAuction.admin.ManageCategory" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <title> Quản trị - Quản lý danh mục</title>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphBody" runat="server">
<center>
    <div class="fullwidth" >
        <div class="content-head" > Danh mục sản phẩm</div>
                <div class="content-body" > 
                    
                    <asp:GridView ID="GridView1" runat="server" AllowPaging="True" 
                        AutoGenerateColumns="False" CellPadding="4" DataKeyNames="CategoryID" 
                        DataSourceID="SqlDataSource1" ForeColor="#333333" GridLines="None" 
                        ShowFooter="True">
                        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                        <Columns>
                            <asp:TemplateField>
                                <ItemTemplate>
                                    <asp:ImageButton ID="ImageButtonEdit" runat="server" Height="20px" 
                                        ImageUrl="~/images/items/edit.jpg" Width="20px" CommandName="Edit" />
                                    <asp:ImageButton ID="ImageButtonDelete" runat="server" CommandName="Delete" 
                                        Height="20px" ImageUrl="~/images/items/delete.jpg" 
                                        onclientclick="return confirm('Bạn có thật sự muốn xoá?');" Width="20px" />
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:LinkButton ID="LinkButton3" runat="server" CommandName="Update">Cập nhật</asp:LinkButton>
                                    <asp:LinkButton ID="LinkButton4" runat="server" CausesValidation="False" 
                                        CommandName="Cancel">Huỷ</asp:LinkButton>
                                </EditItemTemplate>
                                <FooterTemplate>
                                    <asp:LinkButton ID="LinkButton5" runat="server" onclick="LinkButton5_Click">Thêm mới</asp:LinkButton>
                                </FooterTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Mã danh mục" InsertVisible="False" 
                                SortExpression="CategoryID">
                                <ItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryID") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:Label ID="Label1" runat="server" Text='<%# Eval("CategoryID") %>'></asp:Label>
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Tên danh mục" SortExpression="CategoryName">
                                <ItemTemplate>
                                    <asp:Label ID="Label2" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryName") %>'></asp:TextBox>
                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                                        ControlToValidate="TextBox1" ErrorMessage="*" SetFocusOnError="True">Trường bắt buộc</asp:RequiredFieldValidator>
                                </EditItemTemplate>
                            </asp:TemplateField>
                            <asp:TemplateField HeaderText="Mô tả" SortExpression="Description">
                                <ItemTemplate>
                                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("Description") %>'></asp:Label>
                                </ItemTemplate>
                                <EditItemTemplate>
                                    <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description") %>'></asp:TextBox>
                                </EditItemTemplate>
                            </asp:TemplateField>
                        </Columns>
                        <EditRowStyle BackColor="#999999" />
                        <EmptyDataTemplate>
                            Nhập thông tin danh mục mới<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" 
                                DataKeyNames="CategoryID" DataSourceID="SqlDataSource1" DefaultMode="Insert" 
                                Height="50px" Width="435px" CellPadding="4" ForeColor="#333333" 
                                GridLines="None" oniteminserted="DetailsView1_ItemInserted">
                                <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
                                <CommandRowStyle BackColor="#E2DED6" Font-Bold="True" />
                                <EditRowStyle BackColor="#999999" />
                                <FieldHeaderStyle BackColor="#E9ECF1" Font-Bold="True" />
                                <Fields>
                                    <asp:BoundField DataField="CategoryID" HeaderText="Mã danh mục" 
                                        InsertVisible="False" ReadOnly="True" SortExpression="CategoryID" />
                                    <asp:TemplateField HeaderText="Tên danh mục" SortExpression="CategoryName">
                                        <ItemTemplate>
                                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("CategoryName") %>'></asp:Label>
                                        </ItemTemplate>
                                        <EditItemTemplate>
                                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryName") %>'></asp:TextBox>
                                        </EditItemTemplate>
                                        <InsertItemTemplate>
                                            <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("CategoryName") %>'></asp:TextBox>
                                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                                                ControlToValidate="TextBox1" ErrorMessage="*" SetFocusOnError="True">Trường bắt buộc</asp:RequiredFieldValidator>
                                        </InsertItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="Description" HeaderText="Mô tả" 
                                        SortExpression="Description" />
                                    <asp:TemplateField>
                                        <InsertItemTemplate>
                                            <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Insert">Thêm</asp:LinkButton>
                                            <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" 
                                                CommandName="Cancel" onclick="LinkButton2_Click">Huỷ</asp:LinkButton>
                                        </InsertItemTemplate>
                                    </asp:TemplateField>
                                </Fields>
                                <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                                <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                            </asp:DetailsView>
                        </EmptyDataTemplate>
                        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
                        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
                        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
                        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
                        <SortedAscendingCellStyle BackColor="#E9E7E2" />
                        <SortedAscendingHeaderStyle BackColor="#506C8C" />
                        <SortedDescendingCellStyle BackColor="#FFFDF8" />
                        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
                    </asp:GridView>
                    <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
                        ConflictDetection="CompareAllValues" 
                        ConnectionString="<%$ ConnectionStrings:ApplicationServices %>" 
                        DeleteCommand="DELETE FROM [Category] WHERE [CategoryID] = @original_CategoryID AND (([CategoryName] = @original_CategoryName) OR ([CategoryName] IS NULL AND @original_CategoryName IS NULL)) AND (([Description] = @original_Description) OR ([Description] IS NULL AND @original_Description IS NULL))" 
                        InsertCommand="INSERT INTO [Category] ([CategoryName], [Description]) VALUES (@CategoryName, @Description)" 
                        OldValuesParameterFormatString="original_{0}" 
                        SelectCommand="SELECT * FROM [Category]" 
                        UpdateCommand="UPDATE [Category] SET [CategoryName] = @CategoryName, [Description] = @Description WHERE [CategoryID] = @original_CategoryID AND (([CategoryName] = @original_CategoryName) OR ([CategoryName] IS NULL AND @original_CategoryName IS NULL)) AND (([Description] = @original_Description) OR ([Description] IS NULL AND @original_Description IS NULL))">
                        <DeleteParameters>
                            <asp:Parameter Name="original_CategoryID" Type="Int32" />
                            <asp:Parameter Name="original_CategoryName" Type="String" />
                            <asp:Parameter Name="original_Description" Type="String" />
                        </DeleteParameters>
                        <InsertParameters>
                            <asp:Parameter Name="CategoryName" Type="String" />
                            <asp:Parameter Name="Description" Type="String" />
                        </InsertParameters>
                        <UpdateParameters>
                            <asp:Parameter Name="CategoryName" Type="String" />
                            <asp:Parameter Name="Description" Type="String" />
                            <asp:Parameter Name="original_CategoryID" Type="Int32" />
                            <asp:Parameter Name="original_CategoryName" Type="String" />
                            <asp:Parameter Name="original_Description" Type="String" />
                        </UpdateParameters>
                    </asp:SqlDataSource>
                    
                </div>
                <div class="content-foot" > 
                    
                </div>
            </div>
</center>
</asp:Content>
